package io.quick.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class ResultVO extends HashMap<String, Object> {

    private static final long serialVersionUID = 1L;

    public ResultVO() {
        put("code", 0);
    }

    public static ResultVO error() {
        return error(500, "未知异常，请联系管理员" );
    }

    public static ResultVO error(String msg) {
        return error(500, msg);
    }

    public static ResultVO error(int code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.put("code", code);
        resultVO.put("msg", msg);
        return resultVO;
    }

    public static ResultVO ok(String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.put("msg", msg);
        return resultVO;
    }

    public static ResultVO ok(Map<String, Object> map) {
        ResultVO resultVO = new ResultVO();
        resultVO.putAll(map);
        return resultVO;
    }

    public static ResultVO ok() {
        return new ResultVO();
    }

    @Override
    public ResultVO put(String key, Object value) {
        super.put(key, value);
        return this;
    }

}
